#include "Stage.h"

Stage::Stage(void)
{
}

Stage::~Stage(void)
{
}

bool Stage::Init()
{
	m_boardType = TYPE_STAGE;
	m_attribute = ATTR_SHOW;
	SetBoardPos(0.0f, 0.0f);
	SetBoardSize(1024, 768);
	Board::Init();
	return true;
}

bool Stage::Frame()
{
	Board::Frame();

	std::list<Board*>::iterator iter_pos;
	std::list<Board*>::iterator iter_erase;
	bool testB = false;
	if(GetFocusBoard() != 0 && GetFocusBoard() != this)
	{
		for( iter_pos = m_ChildBoardList.begin(); iter_pos != m_ChildBoardList.end(); ++iter_pos)
		{
			if( (*iter_pos) == GetFocusBoard() )
			{
				iter_erase = iter_pos;
				testB = true;
			}
		}
		if( testB )
		{
			Board* pTmpBoard = (*iter_erase);
			m_ChildBoardList.erase(iter_erase);
			m_ChildBoardList.push_back(pTmpBoard);
		}
	}

	for( iter_pos = m_ChildBoardList.begin(); iter_pos != m_ChildBoardList.end(); ++iter_pos)
	{
		(*iter_pos)->Frame();
	}
	return true;
}

bool Stage::Render()
{
	Board::Render();
	std::list<Board*>::iterator iter_pos;
	for( iter_pos = m_ChildBoardList.begin(); iter_pos != m_ChildBoardList.end(); ++iter_pos)
	{
		(*iter_pos)->Render();
	}
	return true;
}

bool Stage::Release()
{
	Board::Release();
	return true;
}

void Stage::InputProcess()
{
	Board::InputProcess();

	if( m_pInput->IsKeyUpFirst(VK_LBUTTON) )
	{
		SetActiveBoard(false);
		ReleaseCaptureBoard();
	}		
}
